package com.walterlife.javacore;

import java.lang.Thread;
import java.util.logging.Level;
import java.util.logging.Logger;

public class StopThread {
    public static void main (String [] args) {
    
    }
}

class Runner implements Runnable {
    boolean exit = false;

    // 控制 线程退出
    public void exit(boolean exit) {
        this.exit = exit; 
    } 

    public void run() {
        while (!exit) {
            System.out.print("Thread is running\n");
            try {
                Thread.sleep(20); 
            } catch(InterruptedException ex) {
                Logger.getLogger(Runner.class.getName()).log(Level.SEVERE, null, ex);            
            }
        } 
    } 
} 

